//
//  UIBarButtonItem+createImage.swift
//  jackWu
//
//  Created by Lewhaming on 2016/11/22.
//  Copyright © 2016年 IQ. All rights reserved.
//

import UIKit

extension UIBarButtonItem{
    //1.用于快送创建一个对象
    //2.依赖制定的方法
    convenience init(imageName:String, target: AnyObject?, action:Selector) {
        let btn = UIButton()
        btn.setImage(UIImage(named:imageName), for: UIControlState.normal)
        btn.setImage(UIImage(named:imageName + "_highlighted"), for: UIControlState.highlighted)
        
        btn.sizeToFit()
        btn.addTarget(target, action: action, for: UIControlEvents.touchUpInside)
        self.init(customView: btn)
    }
}
